package cn.tedu.imop.attach.service;

import cn.tedu.imop.api.domain.Attach;
import cn.tedu.imop.attach.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 本地文件存储
 */
@Primary
@Service
public class LocalAttachServiceImpl implements AttachService
{
    /**
     * 上传文件存储在本地的根路径
     */
    @Value("${file.path}")
    private String localFilePath;

    /**
     * 本地文件上传接口
     * 
     * @param file 上传的文件
     * @return 访问地址
     * @throws Exception
     */
    @Override
    public String uploadAttach(MultipartFile file) throws Exception {
        String name = FileUploadUtils.upload(localFilePath, file);
        return name;
    }

    @Override
    public Boolean batchUpdateBusiness(List<Attach> params) {
        return null;
    }


}
